import { IFormSchema, IFormConfig } from '@/components/CFormDetail/src/form-detail';
import { rules } from './rules';
import { reactive } from 'vue';
import { useRoute } from 'vue-router';

export const useDetail = (isCopyEdit: boolean) => {
  const route = useRoute();
  const { inventoryNo } = route.query;

  const formData = reactive({
    inventoryNo: '',
    organizationCode: '',
    organizationName: '',
    applicableYear: '2023',
    companyName: '',
    companyAddress: '',
    contact: '',
    contactEmail: '',
    contactPhone: '',
    boundary: '',
    planarGraphName: '',
    planarGraphUrl: '',
    fillFrequency: '',
    auditorId: '',
    auditor: '',
    auditorEmail: '',
    planarFileList: [] as any[]
  });

  const schemasProduct: IFormSchema[] = [
    {
      label: '组织名称',
      field: 'organizationCode',
      slot: 'organizationCodeSlot',
      required: true
    },
    {
      label: '适用年份',
      field: 'applicableYear',
      slot: 'applicableYearSlot',
      required: true
    },
    {
      label: '企业名称',
      field: 'companyName',
      type: 'input',
      disabled: true,
      placeholder: '选择组织后，自动带出',
      required: true
    },
    // {
    //   label: '公司经营地址',
    //   field: 'companyAddress',
    //   type: 'input',
    //   disabled: true,
    //   style: 'width: 460px',
    //   placeholder: '选择组织后，自动带出',
    //   required: true
    // },
    {
      label: '联系人',
      field: 'contact',
      type: 'input',
      disabled: true,
      placeholder: '选择组织后，自动带出',
      required: true
    },
    // {
    //   label: '联系电话',
    //   field: 'contactPhone',
    //   type: 'input',
    //   disabled: true,
    //   placeholder: '选择组织后，自动带出',
    //   required: true
    // },
    // {
    //   label: '联系邮箱',
    //   field: 'contactEmail',
    //   type: 'input',
    //   disabled: true,
    //   style: 'width: 460px',
    //   placeholder: '选择组织后，自动带出',
    //   required: true
    // },
    {
      label: '组织边界',
      field: 'boundary',
      type: 'textarea',
      required: true,
      style: 'width: 612px',
      tip: `组织实施经营或财务控制或拥有股份的活动或设施的分组
      推荐写法：
      xxx地址上的工厂内的所有设施与活动。`
    },
    {
      label: '填报频次',
      field: 'fillFrequency',
      slot: 'fillFrequencySlot',
      required: true
    },
    {
      label: '审核人',
      field: 'auditor',
      slot: 'auditorSlot',
      required: true
    }
  ];
  const schemasOther: IFormSchema[] = [
    {
      label: '厂区平面图',
      field: 'planarFileList',
      type: 'upload'
    }
  ];
  const formConfig: IFormConfig = {
    rules
  };
  return {
    schemasProduct,
    schemasOther,
    formConfig,
    formData
  };
};
